home *** CD-ROM | disk | FTP | other *** search
/ Whiteline: delta / whiteline CD Series - delta.iso / tex / style / misc / bezier.doc < prev    next >
Text File  |  1995-11-25  |  4KB  |  120 lines

  1. % BEZIER DOCUMENT-STYLE OPTION - released 17 December 1985
  2. %    for LaTeX version 2.09
  3. % Copyright (C) 1985 by Leslie Lamport
  4.  
  5. %  In a picture environment, writing
  6. %
  7. %       \bezier{N}(AX,AY)(BX,BY)(CX,CY)
  8. %
  9. %  plots a quadratic Bezier curve from (AX,AY) to (CX,CY), with (BX,BY) as
  10. %  the third Bezier point, using N+1 equally spaced points.
  11. %
  12. %  \bezier{N}(AX,AY)(BX,BY)(CX,CY) ==
  13. %    BEGIN
  14. %      @sc  := N
  15. %      @scp := @sc+1
  16. %      \@xb := 2 * (BX - AX) * \unitlength
  17. %      \@xa := ((CX-AX)*\unitlength - \@xb)/@sc
  18. %      \@yb := 2 * (BY - AY) * \unitlength
  19. %      \@ya := ((CY-AY)*\unitlength - \@yb)/@sc
  20. %      \@pt := square rule of width \@wholewidth
  21. %      @t := 0
  22. %      WHILE @t < @scp
  23. %        DO  \@x := ((@t*\@xa + @xb) / @sc) * t
  24. %            \@y := ((@t*\@ya + @yb) / @sc) * t
  25. %            plot pt with relative coords (\@x,\@y)
  26. %            @t := @t+1
  27. %        OD
  28.  
  29. \newcounter{@sc}
  30. \newcounter{@scp}
  31. \newcounter{@t}
  32. \newlength{\@x}
  33. \newlength{\@xa}
  34. \newlength{\@xb}
  35. \newlength{\@y}
  36. \newlength{\@ya}
  37. \newlength{\@yb}
  38. \newsavebox{\@pt}
  39.  
  40. \def\bezier#1(#2,#3)(#4,#5)(#6,#7){\c@@sc#1\relax
  41.   \c@@scp\c@@sc \advance\c@@scp\@ne
  42.   \@xb #4\unitlength \advance\@xb -#2\unitlength \multiply\@xb \tw@
  43.   \@xa #6\unitlength \advance\@xa -#2\unitlength
  44.       \advance\@xa -\@xb \divide\@xa\c@@sc
  45.   \@yb #5\unitlength \advance\@yb -#3\unitlength \multiply\@yb \tw@
  46.   \@ya #7\unitlength \advance\@ya -#3\unitlength
  47.       \advance\@ya -\@yb \divide\@ya\c@@sc
  48.   \setbox\@pt\hbox{\vrule height\@halfwidth  depth\@halfwidth 
  49.    width\@wholewidth}\c@@t\z@   
  50.    \put(#2,#3){\@whilenum{\c@@t<\c@@scp}\do
  51.       {\@x\c@@t\@xa \advance\@x\@xb \divide\@x\c@@sc \multiply\@x\c@@t 
  52.        \@y\c@@t\@ya \advance\@y\@yb \divide\@y\c@@sc \multiply\@y\c@@t 
  53.        \raise \@y \hbox to \z@{\hskip \@x\unhcopy\@pt\hss}\advance\c@@t\@ne}}}
  54.  
  55.  
  56. %  of commands of the type specified below, does the following, 
  57. %  where t, dt, dx, and dy are counters, 
  58. %
  59. %        t  := 0
  60. %        dt := DT
  61. %        dx := 0
  62. %        dy := 0
  63. %        WHILE t < MAX 
  64. %          DO  plot the point (X + (dx/SCALE)), Y + (dy/SCALE))
  65. %              t := t + dt
  66. %              execute COMMANDS
  67. %          OD
  68. %
  69. % COMMANDS may include only the commands \set, \add, \mul, or \div,
  70. % defined as follows, where
  71. %           CTR == counter name, 
  72. %           VAL == either an integer (like 2145 or -7), or
  73. %                  \value{CTR'}, where CTR' a counter name, or
  74. %                  -\value{CTR'}
  75. %
  76. %      \set{CTR}{VAL} 
  77. %         This command performs the operation  CTR := VAL
  78. %   
  79. %      \add{CTR}{VAL}
  80. %          Performs the operation  CTR := CTR + VAL
  81. %   
  82. %      \mul{CTR}{VAL}
  83. %          Performs the operation  CTR := CTR * VAL
  84. %   
  85. %      \div{CTR}{VAL}
  86. %          Performs the operation  CTR := CTR / VAL
  87. %          (this is integer division, with 5/3 = 1 and -5/3 = 5/(-3) = -1)
  88. %
  89. %  There should be no spaces in COMMANDS.  However, the command \  can
  90. %  be used for readabiilty--e.g.,
  91. %       \set{foo}{dt}\  \mul{foo}{3}
  92. %
  93. %
  94. %  HINTS:  
  95. %    \plot'ing takes a long time, so start with DT large, and make it small
  96. %     only for the final draft.
  97. %
  98.  
  99. %\newcounter{t}
  100. %\newcounter{dt}
  101. %\newcounter{dx}
  102. %\newcounter{dy}
  103. %
  104. %\def\set#1#2{\csname c@#1\endcsname#2}
  105. %\def\@div#1#2{\divide\csname c@#1\endcsname#2}
  106. %\def\mul#1#2{\multiply\csname c@#1\endcsname#2}
  107. %\def\add#1#2{\advance\csname c@#1\endcsname#2}
  108. %
  109.  
  110.  
  111.  
  112. %\def\plot#1#2#3#4{\let\div\@div \def\ {}\c@t\z@ \c@t\z@ 
  113. %  \c@dt#1\c@dx\z@ \c@dy\z@\edef\@tempa{#4}\@tempdima\unitlength
  114. %  \divide\@tempdima #3\relax
  115. %  \setbox\@pt\hbox{\vrule height\@halfwidth  depth\@halfwidth 
  116. %   width\@wholewidth}\@whilenum{\c@t<#2}\do
  117. %  {\raise \c@dy\@tempdima \hbox to \z@{\hskip \c@dx\@tempdima\unhcopy\@pt\hss
  118. %                                      }\advance\c@t\c@dt\@tempa}}
  119. %
  120.